package android.fwirk;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;

import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class StartupActivity extends TabActivity {
	TabHost tabHost;
	TabSpec homeTS;
	Intent homeIntent;
	TabSpec plurkTS;
	Intent plurkIntent;
	TabSpec facebookTS;
	Intent facebookIntent;
	TabSpec twitterTS;
	Intent twitterIntent;
	boolean canFacebook;
	boolean canTwitter;
	boolean canPlurk;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabs);
        tabHost = getTabHost();
        tabHost.setup();       
        Bundle b=getIntent().getExtras();
        canFacebook=false;
        canTwitter=false;
        canPlurk=false;
        if(b!=null) { 
	        canFacebook=b.getBoolean("canFacebook",false);
	        canTwitter=b.getBoolean("canTwitter",false);
	        canPlurk=b.getBoolean("canPlurk",false);
    	}
        Resources res = getResources(); // Resource object to get Drawables
        homeIntent=new Intent(this,HomeActivity.class);
        homeIntent.putExtras(b);
        homeTS=tabHost.newTabSpec("Home")
        	.setIndicator("Home",res.getDrawable(R.drawable.homeicon))                  
        	.setContent(homeIntent);
        tabHost.addTab(homeTS);
        facebookIntent=new Intent(this,FacebookActivity.class);
        facebookTS=tabHost.newTabSpec("Facebook")
        	.setIndicator("Facebook",res.getDrawable(R.drawable.facebookhead))                  
        	.setContent(facebookIntent);
        if(canFacebook) {
        	tabHost.addTab(facebookTS);
        }
        twitterIntent=new Intent(this,TwitterActivity.class);
        twitterTS=tabHost.newTabSpec("Twitter")
        	.setIndicator("Twitter",res.getDrawable(R.drawable.twitterhead))                  
        	.setContent(twitterIntent);
        if(canTwitter) {
        	tabHost.addTab(twitterTS);
        }
        plurkIntent=new Intent(this,PlurkActivity.class);
        plurkTS=tabHost.newTabSpec("Plurk")
        	.setIndicator("Plurk",res.getDrawable(R.drawable.plurkhead))                  
        	.setContent(plurkIntent);
        if(canPlurk) {
        	tabHost.addTab(plurkTS);
        }
        tabHost.setCurrentTabByTag("Home");
    }
    
    
}